﻿/*
 * Created by SharpDevelop.
 * User: christophe
 * Date: 12/03/2011
 * Time: 15:39
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Windows.Data;

namespace MetaVideoEditorEvolved.Converter
{
	/// <summary>
	/// Description of UriToLocalPathConverter.
	/// </summary>
	public class UriToLocalPathConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			string param = parameter as string;
			string path = value as string;

			var localImagePath =  mveEngine.ImageUtil.GetLocalImagePath(path);
			
			if (string.IsNullOrEmpty(path) ||
			    string.IsNullOrEmpty(localImagePath))
			{
				if (param != null && param == "Actor")
				{
					return "./Images/MissingPerson.jpg";
				}

				return null;
			}

			return localImagePath;
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}
}
